Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved aggrMethod to accept multiple values #605

Merged
merged 7 commits into from
Nov 22, 2024

Conversation

Madhu1029
Copy link
Contributor

Fixes #432 partially.
aggrMethod can take multiple aggregations using comma separation.

@Madhu1029
Copy link
Contributor Author

Hi @fgalan ,

If PR seems ok, please merge the PR.
Thanks

@@ -1 +1,2 @@
- Improved aggrMethod to accept multiple values (#432, partial)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Improved aggrMethod to accept multiple values (#432, partial)
- Add: aggrMethod accept multiple values separated by comma (#432, partial)
- Add: aggrMethod 'all' to get all the possible aggregations (#432, partial)

In addition, documentation at doc/manuals/aggregated-data-retrieval.md (aggrMethod bullet) should be modified to explain the new functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in ee9cded

@@ -912,21 +912,22 @@ function aggregatedDataAvailableSinceDateTest(ngsiVersion, params, done) {
break;
}

let value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of modifying existing tests, please add new ones. In particular, I'd suggest two new tests cases:

  • Using the 'all' token
  • Using two aggregation methods (whatever) separated by ","

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fgalan,

I have added the new test cases here.

Previously, only one aggrMethod was there so switch case was working fine. But in case of multiple aggregation method we need to update the code for multiple values separately. The above code change is for util class to accommodate the multiple aggregation methods.

@Madhu1029
Copy link
Contributor Author

Hi @fgalan ,
I have updated the docs. Please merge this PR if it seems ok.

Thanks

Comment on lines 66 to 68
const list = ['min', 'max', 'sum', 'sum2', 'occur', 'all'];
const joinedList = '(' + list.join('|') + ')';
const regex = new RegExp('^' + joinedList + '(,' + joinedList + ')*$');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use more meaningful names names for the variables. For instance:

Suggested change
const list = ['min', 'max', 'sum', 'sum2', 'occur', 'all'];
const joinedList = '(' + list.join('|') + ')';
const regex = new RegExp('^' + joinedList + '(,' + joinedList + ')*$');
const aggList = ['min', 'max', 'sum', 'sum2', 'occur', 'all'];
const joinedAggList = '(' + aggList.join('|') + ')';
const aggRegex = new RegExp('^' + joinedAggList + '(,' + joinedAggList + ')*$');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3b51b4c

provided by these aggregated methods with the number of samples, it is possible to calculate probabilistic values
such as the average value, the variance as well as the standard deviation. It is a mandatory parameter.
samples) for numeric attribute values and `occur` for attributes values of type string. It accepts multiple values
separated by comma (min,max) to get multiple aggregation method values. Additionally, `aggrMethod=all` can be used
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
separated by comma (min,max) to get multiple aggregation method values. Additionally, `aggrMethod=all` can be used
separated by comma (eg. `aggrMethod=min,max`) to get multiple aggregation method values. Additionally, `aggrMethod=all` can be used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3b51b4c

@@ -324,13 +324,45 @@ describe('sth tests', function() {
})
);

it(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to add a couple of cases:

  • should respond with 400 - Bad Request if aggMethod is not a valid one (e.g. aggMethod=foo)
  • should respond with 400 - Bad Request if aggMethod mixes a valid one with a not valid one (eg. aggMethod=max,foo)

Btw, what happens if aggMethod mixes all with another method? Eg. aggMethod=all,min? Do we get and error or the "min" part is ignored and that's equivalent to aggMethod=all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test cases in 3b51b4c

If aggMethod mixes all with another method e.g. aggMethod=all,min, then it is equivalent to aggMethod=all ignoring all other parameters.

@Madhu1029
Copy link
Contributor Author

Hi @fgalan ,

I have updated all the suggestions mentioned by you in previous comment.
I request you to please review the PR.

@fgalan
Copy link
Member

fgalan commented Oct 3, 2023

Hi @fgalan ,

I have updated all the suggestions mentioned by you in previous comment. I request you to please review the PR.

Thanks for your contribution! We would have a look to the PR the soon as possible.

@Madhu1029
Copy link
Contributor Author

Hi @fgalan ,

Could you please have a look on this PR?

@AlvaroVega
Copy link
Member

Is this a new feature or extends and modify a current one?
Should documentation be updated ?

@Madhu1029
Copy link
Contributor Author

Is this a new feature or extends and modify a current one? Should documentation be updated ?

Hi @AlvaroVega ,
Thanks for your response.
Currently, we can only specify single aggrMethod like aggrMethod=sum or aggrMethod=min but with this PR we can specify multiple aggrMethod in single go like aggrMethod=sum,min,max. In addition to this, aggrMethod=all will give all the aggregation method results in one go.

Documentation for this is already updated in this PR.

Copy link
Member

@fgalan fgalan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@AlvaroVega AlvaroVega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AlvaroVega AlvaroVega merged commit 359b095 into telefonicaid:master Nov 22, 2024
6 checks passed
@fgalan
Copy link
Member

fgalan commented Nov 22, 2024

@Madhu1029 thanks for your contribution! Sorry for the delay merging this PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve aggrMethod
3 participants